/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xtd.model.retail;

import com.xtd.model.employment.DepartmentPost;
import com.xtd.model.employment.Employee;
import com.xtd.model.inventory.CommodityRoyalty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author Lu Yuanbin
 */
@Entity
@Table(name = "order_server")
public class OrderServer implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @JoinColumn(name = "order_commodity", referencedColumnName = "id", insertable = true, updatable = true)
    @ManyToOne(optional = false)
    private OrderCommodity orderCommodity;
    @JoinColumn(name = "department_post", referencedColumnName = "id")
    @ManyToOne
    private DepartmentPost departpost;
    @JoinColumn(name = "server", referencedColumnName = "id")
    @ManyToOne
    private Employee server;
    @Column(name = "quantity_royalty")
    private BigDecimal quantityRoyalty;
    @Column(name = "price_royalty")
    private BigDecimal priceRoyalty;
    @Column(name = "introducer_royalty")
    private BigDecimal introducerRoyalty;
    @Column(name = "settledTime")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date settledTime;

    public OrderServer() {
    }

    public OrderServer(OrderCommodity oc) {
        this.orderCommodity = oc;
    }

    public OrderServer(OrderCommodity orderCommodity, CommodityRoyalty commodityRoyalty) {
        this.orderCommodity = orderCommodity;
        this.quantityRoyalty = commodityRoyalty.getQuantityRoyalty();
        this.priceRoyalty = commodityRoyalty.getPriceRoyalty();
        this.departpost = commodityRoyalty.getDepartmentPost();

    }

    public OrderServer(OrderCommodity oc, DepartmentPost dp) {

        this.departpost = dp;

        this.orderCommodity = oc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrderServer)) {
            return false;
        }
        OrderServer other = (OrderServer) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.xtd.model.retail.OrderServer[id=" + id + "]";
    }

    /**
     * @return the departpost
     */
    public DepartmentPost getDepartpost() {
        return departpost;
    }

    /**
     * @param departpost the departpost to set
     */
    public void setDepartpost(DepartmentPost departpost) {
        this.departpost = departpost;
    }

    /**
     * @return the server
     */
    public Employee getServer() {
        return server;
    }

    /**
     * @param server the server to set
     */
    public void setServer(Employee server) {

        this.server = server;
    }

    public String getServerInfo() {
        if (departpost != null) {
            return departpost.toString();
        } else {
            return "介绍人";
        }
    }

    /**


    /**
     * @return the orderCommodity
     */
    public OrderCommodity getOrderCommodity() {
        return orderCommodity;
    }

    /**
     * @param orderCommodity the orderCommodity to set
     */
    public void setOrderCommodity(OrderCommodity orderCommodity) {
        this.orderCommodity = orderCommodity;
    }

    /**
     * @return the quantityRoyalty
     */
    public BigDecimal getQuantityRoyalty() {
        return quantityRoyalty;
    }

    /**
     * @param quantityRoyalty the quantityRoyalty to set
     */
    public void setQuantityRoyalty(BigDecimal quantityRoyalty) {
        this.quantityRoyalty = quantityRoyalty;
    }

    /**
     * @return the priceRoyalty
     */
    public BigDecimal getPriceRoyalty() {
        return priceRoyalty;
    }

    /**
     * @param priceRoyalty the priceRoyalty to set
     */
    public void setPriceRoyalty(BigDecimal priceRoyalty) {
        this.priceRoyalty = priceRoyalty;
    }

    /**
     * @return the introducerRoyalty
     */
    public BigDecimal getIntroducerRoyalty() {
        return introducerRoyalty;
    }

    /**
     * @param introducerRoyalty the introducerRoyalty to set
     */
    public void setIntroducerRoyalty(BigDecimal introducerRoyalty) {
        this.introducerRoyalty = introducerRoyalty;
    }

    /**
     * @return the settledTime
     */
    public Date getSettledTime() {
        return settledTime;
    }

    /**
     * @param settledTime the settledTime to set
     */
    public void setSettledTime(Date settledTime) {
        this.settledTime = settledTime;
    }
}
